<?php
require_once('../lib/php-html-generator.php');
error_reporting(E_ALL ^ E_NOTICE);

/*$div = new Div('abc');
$div->addInner( new Span('a', new label('x','Labão')  ) );
$div->addInner( new Span('v', 'ancv') );
$div->addInner( new Span('c', 'ancc') );

//$span = new Span('d','abcfds');

$pre = new pre(null , print_r($div,1) );

echo $pre;

//echo $span;

echo $div;*/

global $page;
$page = new page('Novo Título');
$page->addCss('example.css');
$page->addScript('../lib/js/php-html-generator.js');
$page->addScript('../lib/js/prototype.js');
$page->addScript('../lib/js/genericDrag.js');
//$page       ->addJsCode('alert(\'uhuaha\');');

class TestForm extends DivForm
{
    public function __construct()
    {
        $fields[]   = new Text('text', $_REQUEST['text'], 'text', 'Texto' );
        $fields[]   = new Password('password', $_REQUEST['password'], 'text', 'Senha' );
        $fields[]   = new SSelect('select', $_REQUEST['select'], array('a','b','c'), 'text', 'Seleção' );
        $fields[]   = new CheckBox('checkbox', $_REQUEST['checkbox'], $_REQUEST['checkbox'], 'checkbox' , 'Caixa de Checagem');
        $fields[]   = new Img('img', 'ball_green.png', null);
        $fields[]   = array(new text('a','a','text','Multiple Fields'), new button('button', 'Alert', 'alert(\'Alert\')', 'text') );
        $fields[]   = new PureHtml('<b>some pure Html!</b>');
        $fields[]   = new Dummy('Dummy');
        $fields[]   = new Submit('postar', 'Postar', 'text', null);
        $fields[]   = new Button('jsPost2', 'Ajax', "ajax('ajaxReturn','TestForm:jsPost')", 'text');
        $fields[]   = new Div('ajaxReturn', 'uhu');
        $form       = new Easyform(null, $fields,null, null,null,'form');

        parent::__construct( 'divForm01', $form, '400px', '240px', 'New Form', 'formTitle');

    }

    function jsPost()
    {
        $fields[] = $label = new Label(null, 'Este é um poste em ajax. Não questione.', 'comeGetSome');
        $fields[] = new Text('comeGetSome', '', 'text', 'Something');
        $fields[] = new Script("alert('Ajax alert')");
        $fields[] = new Pre(null ,print_r($_REQUEST,true) );
        return $fields;
    }
}

$page->addContent( new TestForm() );
echo $page;
?>